package com.domain.pojo;

import com.domain.DO.FlightClass;
import lombok.AllArgsConstructor;
import org.springframework.util.Assert;

/**
 * @author 大忽悠
 * @create 2022/11/14 19:45
 */
@AllArgsConstructor
public enum FlightClassLevel {
    POOR(0),RICH(1);

    private Integer level;

    public static void seatNumCheck(Integer flightClassLevel, FlightClass flightClass){
           if(RICH.level.equals(flightClassLevel)){
               Assert.isTrue(flightClass.getRichLeftNumber()>0,"商务舱无剩余座位");
           }else {
               Assert.isTrue(flightClass.getPoorLeftNumber()>0,"经济舱无剩余座位");
           }
    }

    public static void decreeNum(Integer flightClassLevel, FlightClass flightClass){
        if(RICH.level.equals(flightClassLevel)){
            flightClass.setRichLeftNumber(flightClass.getRichLeftNumber()-1);
        }else {
            flightClass.setPoorLeftNumber(flightClass.getPoorLeftNumber()-1);
        }
    }
}
